import { ConstValues, getTenantId } from './../projectIndicators.config';

export const searchTpl = {
    name: '查询模板',
    col: 4,
    dataSource: 'stopwork_search_area',
    items: [
        {
            itemtype: "refer",
            refType: 'tree',
            refPk: 'pkOrganization',
            refPk1: 'pkTenant',
            label: "项目组织",
            isMultiSelectedEnabled: true,
            required: false,
            selectShowKey: 'sname',
            reqRef: {
                queryCondition: function () {
                   
                    return { pkTenant: getTenantId()}
                },
                method:'get',
                refUrl: "/organization/getPermOrgByUser",
            },
        },
        {
            itemtype: "refer",
            refType: 'grid',
            refPk: 'pkProject',
            label: "项目名称",
            isMultiSelectedEnabled: true,
            required: false,
            selectShowKey: 'sname',
            reqRef: {
                queryCondition: function () {
                    let org = this.search.getSearchValue({ refPk: 'pkSrc', requireKey: ['pkSrc', 'pkTenant']});
                    return {
                        pkOrg: org.length ? org[0] : null
                    }
                },
                setData: (res) => {
                    return res.data.result.objects
                },
                method:'get',
                refUrl: "/projectInTeam/list",
                setCoByKey:[
                    { name: '项目编码', key: 'scode' },
                    { name: '项目名称', key: 'sname'},
                ],
            },
        },
        {
            itemtype: "refer",
            refType: 'grid',
            refPk: 'userId',
            label: "制单人",
            isMultiSelectedEnabled: true,
            required: false,
            selectShowKey: 'userName',
            reqRef: {
                queryCondition: function () {
                    let pkProject = this.search.getSearchValue({ refPk: 'pkProject', requireKey: 'pkProject'});
                    return {
                        pkProject: pkProject.length? pkProject[0] : ''
                    }
                },
                method:'get',
                refUrl: "/billView/getUserRefList",
                setCoByKey:[
                    { name: '制单人', key: 'userName' }
                ]
            },
        },
        {
            itemtype: "section-date",
            refPk: 'sectionDate',
            label: "制单日期",
            isMultiSelectedEnabled: true,
            queryCondition: () => {
                return {}
            },
            refUrl: "uapbd/refer/org/ItemOrgDefaultTreeRef/index",
            required: false,
        },
        {
            itemtype: "select",
            refPk: 'billStatus',
            label: "单据状态",
            initialvalue: { value: 1, display: "自由态" },
            isMultiSelectedEnabled: true,
            isAjax: false,
            reqUrl: '',
            options: ConstValues.Options
        }
    ]
}